//
//  DatabaseCache.h
//  BaiYing_Thinker
//
//  Created by 鹏 朱 on 15/10/21.
//  Copyright (c) 2015年 XKJH. All rights reserved.
//

#import <Foundation/Foundation.h>
@class FMDatabaseQueue;
@class FMDatabase;
@class SubjectMessage;
@class SessionMessage;
@class SessonContentMessage;

#define KTableNameOfSubject              @"t_subject"
#define KTableNameOfSession              @"t_session"
#define KTableNameOfSessionContent       @"t_session_content"

@interface DatabaseCache : NSObject

@property (nonatomic,strong)NSString *m_dbPath;
@property(nonatomic,retain) FMDatabase *db;
@property(nonatomic,retain) FMDatabaseQueue *dbQueue;

+ (instancetype)shareInstance;
- (NSString *)getDbPath;
- (BOOL)createDBWithPath:(NSString *)path;

#pragma mark - 查询某个表的所有记录
- (NSMutableArray *)SelectAllByTableName:(NSString*)name;

#pragma mark - 查询某个表的满足所有and条件的记录
- (NSMutableArray *)SelectAllBycondition:(NSDictionary*)dicCondtion TableName:(NSString*)name orderName:(NSArray *)orderNameList subjectContent:(NSString *)subjectContent;

#pragma mark -  根据表名往表中插入一条记录
- (BOOL)InsertIntoTableFieldDict:(NSDictionary*)dic tableName:(NSString*)name;

#pragma mark - 删除某个表的所有记录
- (BOOL)DeleteAllByTableName:(NSString*)name;

#pragma mark - 删除满足所有and条件的记录
- (BOOL)DeleteBycondition:(NSDictionary*)dicCondtion tableName:(NSString*)name;

#pragma mark - 更新满足所有条件的记录
-(BOOL)UpdateTableField:(NSDictionary*)dic condition:(NSDictionary*)dicCondtion tableName:(NSString*)name;


@end

@interface DatabaseCache(xx_message)

//查询
- (NSMutableArray *)selectDataSource;
- (NSMutableArray *)selectSubjectInfo;
- (NSMutableArray *)selectSessionInfo;
- (NSMutableArray *)selectSessionContentInfo;

//新增
- (void)addSubjectInfo:(SubjectMessage *)info;
- (void)addSessionInfo:(SessionMessage *)info;
- (void)addSessionContentInfo:(SessonContentMessage *)info;

@end
